/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SPARQL;

import java.util.Objects;

/**
 *
 * @author riccardo
 */
public class PrefixedURI extends URI{
        private String prefix;
        private String uri;
        private String base;

    public PrefixedURI(String prefix, String uri, String base) {
        this.prefix = prefix;
        this.uri = uri;
        this.base = base;
    }

        @Override
    public String getUri() {
        return base+uri;
    }

    public SimpleURI getSimpleURI(){
        return new SimpleURI(base+uri);
    }
    
    @Override
    public int hashCode() {
        int hash = 5;
        hash = 97 * hash + Objects.hashCode(this.prefix);
        hash = 97 * hash + Objects.hashCode(this.uri);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if(obj instanceof SimpleURI){
            final SimpleURI other = (SimpleURI) obj;
            if (!Objects.equals(this.getSimpleURI().getUri(), other.getUri())) {
                return false;
            }
        }
        else if(obj instanceof PrefixedURI){
            final PrefixedURI other1 = (PrefixedURI) obj;
            if (!Objects.equals(this.uri, other1.uri)) {
                return false;
            }
            if (!Objects.equals(this.prefix, other1.prefix)) {
                return false;
            }
        }
        else return false;
        return true;
    }
    

    @Override
    public Object clone() {
        return new PrefixedURI(prefix, uri, base);
    }

    @Override
    public String toString() {
        return  prefix + ":" + uri;
    }

        
}
